home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-29 | 737 b | 33 lines | [TEXT/CWIE] |
- // MMUModeSwapper.h, an MMU Mode swapper using the "resource acquisition
- // is initialization" technique, see 9.4 of Stroustrup.
-
- // copyright © 1995, Macneil Shonle. All rights reserved.
-
- #ifndef __MMUMODESWAPPER__
- #define __MMUMODESWAPPER__
-
- // class MMUModeSwapper
- class MMUModeSwapper {
- public:
- MMUModeSwapper(int swapTo32);
- ~MMUModeSwapper();
-
- private:
- int into32;
- SInt8 mode;
- };
-
- // swaps into 32-bit addressing if swapTo32 is true, else keeps the same addressing-mode
- inline MMUModeSwapper::MMUModeSwapper(int swapTo32)
- : into32(swapTo32), mode(true32b)
- {
- if (into32) SwapMMUMode(&mode);
- }
-
- // swaps back to the original addressing mode
- inline MMUModeSwapper::~MMUModeSwapper()
- {
- if (into32) SwapMMUMode(&mode);
- }
-
- #endif